/* eslint-disable no-undef,no-param-reassign,import/named,consistent-return */
/**
 * Created by chengzhenfu on 2019/5/5.
 * Modified by  on .
 *请求方法模块
 */

import Vue from 'vue'
import fetch from './fetch.js'

// // Promise的finally回调 不论成功与否都会调用
// Promise.prototype.finally = function (callback) {
//   let P = this.constructor;
//   return this.then(
//   value  => P.resolve(callback()).then(() => value),
//   reason => P.resolve(callback()).then(() => { throw reason })
//   );
// };

const http={
  get(url,base,config){
    let data={params:base};
    return fetch(url,data,config);
  },
  post(url, data, config){
    // return fetch.post(...arr);
	
	return fetch({
		url: url,
		method: 'post',
		params: data
	});
  },
  put(url,base,config){
    // let data={data:base};
    let data=base;
    return fetch.put(url,data,config)
  },
  delete(url,base,config){
    let data={data:base};
    return fetch.delete(url,data,config);
  }
}
Vue.prototype.$http=http;
export default http;